package com.tianji.aigc.agent;

import cn.hutool.core.util.ObjectUtil;
import com.tianji.aigc.enums.AgentTypeEnum;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.EnumMap;
import java.util.Map;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2025/7/24 17:32
 */
@Component
public class AgentHander implements ApplicationContextAware {

    private static final Map<AgentTypeEnum,Agent> AGENT_MAP = new EnumMap<>(AgentTypeEnum.class);
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        Map<String, Agent> beansOfType = applicationContext.getBeansOfType(Agent.class);
        for (Agent agent : beansOfType.values()) {
            AGENT_MAP.put(agent.getAgentType(),agent);
        }
    }

    public static Agent findAgentByType(AgentTypeEnum agentType){
        return AGENT_MAP.get(agentType);
    }
}
